package com.sg.qcgl.adapter.ball_team.web;

import com.aimoss.core.dto.MultiResponse;
import com.aimoss.core.dto.SingleResponse;
import com.aimoss.core.pojo.PageBean;
import com.sg.qcgl.client.ball_team.BallTeamServiceClient;
import com.sg.qcgl.client.ball_team.dto.command.BallTeamAddCmd;
import com.sg.qcgl.client.ball_team.dto.command.BallTeamUpdateCmd;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.sg.qcgl.app.ball_team.service.BallTeamServiceI;
import com.sg.qcgl.client.ball_team.dto.BallTeamDTO;
import com.sg.qcgl.client.ball_team.vo.BallTeamVO;
import com.sg.qcgl.client.ball_team.dto.BallTeamPageQueryDTO;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @ClassName BallTeamController
 *
 * @author ${author}
 * @date Thu Sep 04 12:28:40 CST 2025
 * @version 1.0
 */
@Tag(name = "球队信息表管理")
@RestController("BallTeamController.v1")
@RequestMapping("/v1/ballTeams")
public class BallTeamController implements BallTeamServiceClient{

    @Autowired
    private BallTeamServiceI ballTeamService;

    @Operation(summary = "分页查询球队信息表", description = "分页查询球队信息表")
    @PostMapping(value = "/page")
    public SingleResponse<PageBean<BallTeamVO>> page(@RequestBody BallTeamPageQueryDTO pageQueryParams) {
        PageBean<BallTeamVO> ballTeamPage = ballTeamService.page(pageQueryParams);
        return SingleResponse.of(ballTeamPage);
    }

    @Operation(summary = "查询球队信息表列表", description = "查询球队信息表列表")
    @PostMapping(value = "/list")
    public MultiResponse<BallTeamVO> list(@RequestBody BallTeamDTO ballTeamDTO) {
        List<BallTeamVO> result = ballTeamService.list(ballTeamDTO);
        return MultiResponse.of(result);
    }

    @Operation(summary = "根据id获取球队信息表详情", description = "查询球队信息表列表")
    @GetMapping(value = "/{id}")
    public SingleResponse<BallTeamVO> findById(@PathVariable("id") Long id) {
        BallTeamVO detail = ballTeamService.findById(id);
        return SingleResponse.of(detail);
    }



    @Operation(summary = "球队信息表保存")
    @PostMapping(value = "/create")
    public SingleResponse<BallTeamVO> create(@RequestBody BallTeamAddCmd ballTeamAddCmd) {
        BallTeamVO detail = ballTeamService.create(ballTeamAddCmd);
        return SingleResponse.of(detail);
    }

    @Operation(summary = "球队信息表更新")
    @PostMapping(value = "/update")
    public SingleResponse<BallTeamVO> update(@RequestBody BallTeamUpdateCmd ballTeamUpdateCmd) {
        BallTeamVO detail = ballTeamService.update(ballTeamUpdateCmd);
        return SingleResponse.of(detail);
    }

    @Operation(summary = "删除球队信息表")
    @PutMapping(value = "/delete")
    public SingleResponse delete(@Valid @NotBlank @RequestParam("id") String id) {
        ballTeamService.delete(Long.valueOf(id));
        return SingleResponse.buildSuccess();
    }



}
